﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
using System.Windows.Markup;
using System.Collections.ObjectModel;
using System.Linq;

namespace Sakura.Silverlight.Extensions
{
	[ContentProperty("Bindings")]
	public class MultiBinding : MarkupExtension
	{
		/// <summary>
		/// 获取或设置用于组合多个绑定数据的字符串表达式。
		/// </summary>
		public string StringFormat
		{
			get;
			set;
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="serviceProvider"></param>
		/// <returns></returns>
		public override object ProvideValue(IServiceProvider serviceProvider)
		{
			var values = from i in this.Bindings
						 select i.ProvideValue(serviceProvider);

			return string.Format(this.StringFormat ?? string.Empty, values.ToArray());
		}


		public PresentationFrameworkCollection<Binding> Bindings
		{
			get;
			private set;
		}

		public MultiBinding()
		{
			//this.Bindings = new PresentationF
		}
	}
}
